import request from '@/utils/request'


// 先获取已有图片
export function getAlreadyExist(businesId) {
  const data = {
    businesId
  }
  return request({
    url: 'api/v2/backend/business/image/index',
    method: 'post',
    data
  })
}

export function submitAllImg(payload) {
  const data = payload
  return request({
    url: 'api/v2/backend/business/image/action',
    method: 'post',
    data
  })
}

// 提交静态码
export function submitStaticCodeImg(payload) {
  const data = payload
  return request({
    url: 'api/v2/backend/business/setting/pay_img',
    method: 'post',
    data
  })
}

// 点击重发
export function bindCardResetSendSms(businessId) {
  const data = {
    businessId
  }
  return request({
    url: 'api/v4/pay/bind_card/send_sms',
    method: 'post',
    data
  })
}

// 银行卡图片 银行卡四元素认证
export function bankcardAuth(payload) {
  const data = payload
  return request({
    url: 'api/v4/tool/tool/bankcard/auth',
    method: 'post',
    data
  })
}

// 【支付】确认绑卡 api
export function bindcardConfirm(payload) {
  const data = payload
  return request({
    url: 'api/v4/pay/bindcard/confirm',
    method: 'post',
    data
  })
}

// 点击验证 验证码有效性验证接口
export function msgCodeValid(payload){
  const data = payload
  return request({
    url: 'api/v4/check/msg_code/valid',
    method: 'post',
    data
  })
}

// 银行卡绑定 【支付】变更银行卡，并发送验证码
export function changeBankCard(payload) {
  const data = payload
  return request({
    url: 'api/v4/pay/change/bank_card',
    method: 'post',
    data
  })
}

// 银行卡绑定 验证码发送短信
export function sendSms(businessId) {
  const data = {
    businessId
  }
  return request({
    url: 'api/v4/send/sms',
    method: 'post',
    data
  })
}

// 实名认证
export function realNameClick(payload) {
  const data = payload
  return request({
    url: 'api/v4/pay/real_name',
    method: 'post',
    data
  })
}

// 上传图片认证
export function uploadImage(payload) {
  const data = payload
  return request({
    url: 'api/v4/pay/upload_image',
    method: 'post',
    data
  })
}

// 开通状态为1 未开通时 编辑保存 第二个tabs的内容
export function saveTabsSecond(payload) {
  const data = payload
  return request({
    url: 'api/v2/backend/business/pay/edit',
    method: 'post',
    data
  })
}

// 身份证正面
export function fetchidCardFrontImg(imgFile, side) {
  const formData = new FormData()
  formData.append('imgFile', imgFile)
  formData.append('side', side)
  const data = formData
  return request({
    url: 'api/v4/tool/idcard/auth',
    method: 'post',
    data
  })
}

// 身份证反面
export function fetchidCardBackImg(imgFile, side) {
  const formData = new FormData()
  formData.append('imgFile', imgFile)
  formData.append('side', side)
  const data = formData
  return request({
    url: 'api/v4/tool/idcard/auth',
    method: 'post',
    data
  })
}

// 银行卡识别
export function fetchBankCardImg(imgFile) {
  const formData = new FormData()
  formData.append('imgFile', imgFile)
  const data = formData
  return request({
    url: 'api/v4/tool/bankcard/shibie',
    method: 'post',
    data
  })
}

// tabs 为 second 时，获得 开通状态
export function dredgeStatus(businessId) {
  const data = { businessId }
  return request({
    url: 'api/v4/business/check/open/payment',
    method: 'post',
    data
  })
}

// 保存 编辑
export function getBusinessAddSave(payload) {
  const data = payload
  return request({
    url: 'api/v2/backend/business/action',
    method: 'post',
    data
  })
}

// 获取 详情
export function getBusinessEditDetails(businessId) {
  const data = { businessId }
  return request({
    url: 'api/v1/backend/business/info',
    method: 'post',
    data
  })
}

// 保存 编辑
export function getBusinessEditSave(payload) {
  const data = payload
  return request({
    url: 'api/v2/backend/business/action',
    method: 'post',
    data
  })
}

// 删除 商户
export function getBusinessDelete(businessId) {
  const data = {
    businessId
  }
  return request({
    url: 'api/v1/backend/business/del',
    method: 'post',
    data
  })
}

// 获取商户列表
export function getBusinessList(searchName, status, businessType, perPage, page) {
  const data = {
    searchName, status, businessType, perPage, page
  }
  return request({
    url: 'api/v1/backend/business',
    method: 'post',
    data
  })
}

// 获取交易信息数据
export function getTransactionList(businessId, perPage, page) {
  const data = {
    businessId, perPage, page
  }
  return request({
    url: 'api/v1/backend/business/transaction',
    method: 'post',
    data
  })
}

// 获取缴费数据
export function getPayTheFeesList(
  businessId, businessName, payStatus, payType, perPage, page
) {
  const data = {
    businessId, businessName, payStatus, payType, perPage, page
  }
  return request({
    url: 'api/v1/backend/pay_the_fees',
    method: 'post',
    data
  })
}

// 获取检测数据
export function getCheckReportList(
  businessId, businessName, perPage, page
) {
  const data = {
    businessId, businessName, perPage, page
  }
  return request({
    url: 'api/v1/backend/check_report',
    method: 'post',
    data
  })
}

// 购进信息详情
export function getPurchaseDetail(
  businessId,
  // type
) {
  const data = {
    businessId,
    // type
  }
  return request({
    url: 'api/v1/backend/purchase/list',
    method: 'post',
    data
  })
}

// 获取合同数据
export function getContractList(
  businessId, status, perPage, page
) {
  const data = {
    businessId, status, perPage, page
  }
  return request({
    url: 'api/v1/backend/market/contract/index',
    method: 'post',
    data
  })
}

// 获取商户详情数据
export function getBusinessDetailsData(
  businessId
) {
  const data = {
    businessId
  }
  return request({
    url: 'api/v1/backend/business/info',
    method: 'post',
    data
  })
}

// 商户退租
export function deleteStall(
  businessId
) {
  const data = {
    businessId
  }
  return request({
    url: 'api/v1/backend/business/change',
    method: 'post',
    data
  })
}

// 上传营业执照 或 商户头像
export function getBusinessImg(
  businessId, type, imgUrl
) {
  const data = {
    businessId, type, imgUrl
  }
  return request({
    url: 'api/v1/backend/business/upload/businessimg',
    method: 'post',
    data
  })
}

// 获取健康证数据
export function getHealthList(
  businessId, perPage, page
) {
  const data = {
    businessId, perPage, page
  }
  return request({
    url: 'api/v1/backend/health',
    method: 'post',
    data
  })
}

// 新增健康证
export function getHealthAddSave(businessId, businessName, healthName, healthPhoto, healthDate) {
  const data = {
    businessId, businessName, healthName, healthPhoto, healthDate
  }
  return request({
    url: 'api/v1/backend/health/add',
    method: 'post',
    data
  })
}

// 删除健康证
export function getHealthDelete(healthId) {
  const data = { healthId }
  return request({
    url: 'api/v1/backend/health/del',
    method: 'post',
    data
  })
}

// 获取许可证数据
export function getLicenseList(
  businessId, perPage, page
) {
  const data = {
    businessId, perPage, page
  }
  return request({
    url: 'api/v1/backend/license',
    method: 'post',
    data
  })
}

// 新增许可证
export function getLicenseAddSave(payload) {
  const data = payload
  return request({
    url: 'api/v1/backend/license/add',
    method: 'post',
    data
  })
}

// 删除许可证
export function getLicenseDelete(otherBusinessLicenseId) {
  const data = { otherBusinessLicenseId }
  return request({
    url: 'api/v1/backend/license/del',
    method: 'post',
    data
  })
}
